import 'package:flutter/material.dart';
import 'comment_section.dart';

class FloatingActionBar extends StatelessWidget {
  final bool isLiked;
  final int likeCount;
  final bool isFavorited;
  final int commentCount;
  final VoidCallback onLike;
  final VoidCallback onFavorite;
  final VoidCallback onComment;
  final String? favoriteTooltip;
  final bool showFavoriteCount;

  const FloatingActionBar({
    super.key,
    required this.isLiked,
    required this.likeCount,
    required this.isFavorited,
    required this.commentCount,
    required this.onLike,
    required this.onFavorite,
    required this.onComment,
    this.favoriteTooltip,
    this.showFavoriteCount = false,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.all(16),
      padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(25),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.1),
            blurRadius: 10,
            offset: const Offset(0, 2),
          ),
        ],
      ),
      child: Row(
        children: [
          // 左侧：说点什么输入区域
          Expanded(
            child: GestureDetector(
              onTap: onComment,
              child: Container(
                padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
                decoration: BoxDecoration(
                  color: Colors.grey[100],
                  borderRadius: BorderRadius.circular(20),
                ),
                child: const Text(
                  '说点什么...',
                  style: TextStyle(
                    color: Colors.grey,
                    fontSize: 14,
                  ),
                ),
              ),
            ),
          ),
          const SizedBox(width: 12),
          // 右侧：操作按钮组
          Row(
            children: [
              // 收藏按钮
              GestureDetector(
                onTap: onFavorite,
                child: Container(
                  padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
                  child: Row(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Icon(
                        isFavorited ? Icons.star : Icons.star_border,
                        color: isFavorited ? Colors.amber : Colors.grey,
                        size: 20,
                      ),
                      // 可选择是否显示收藏数量
                      if (showFavoriteCount) ...[
                        const SizedBox(width: 2),
                        Text(
                          '0', // 暂时固定为0，因为模型中没有此字段
                          style: TextStyle(
                            color: Colors.grey[600],
                            fontSize: 12,
                          ),
                        ),
                      ],
                    ],
                  ),
                ),
              ),
              // 评论按钮
              GestureDetector(
                onTap: onComment,
                child: Container(
                  padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
                  child: Row(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Icon(
                        Icons.chat_bubble_outline,
                        color: Colors.grey[600],
                        size: 20,
                      ),
                      if (commentCount > 0) ...[
                        const SizedBox(width: 2),
                        Text(
                          '$commentCount',
                          style: TextStyle(
                            color: Colors.grey[600],
                            fontSize: 12,
                          ),
                        ),
                      ],
                    ],
                  ),
                ),
              ),
              // 点赞按钮
              GestureDetector(
                onTap: onLike,
                child: Container(
                  padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
                  child: Row(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Icon(
                        isLiked ? Icons.favorite : Icons.favorite_border,
                        color: isLiked ? Colors.red : Colors.grey,
                        size: 20,
                      ),
                      if (likeCount > 0) ...[
                        const SizedBox(width: 2),
                        Text(
                          '$likeCount',
                          style: TextStyle(
                            color: Colors.grey[600],
                            fontSize: 12,
                          ),
                        ),
                      ],
                    ],
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}